package com.egreen.system.service.impl;

import com.egreen.common.pojo.DTO.system.SendFeedbackDTO;
import com.egreen.common.pojo.entity.system.CommodityExchangeRecord;
import com.egreen.common.pojo.entity.system.UserFeedback;
import com.egreen.system.dao.CommodityExchangeRecordDao;
import com.egreen.system.dao.UserFeedbackDao;
import com.egreen.system.service.ICommodityExchangeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author cloudJiang
 * @since 2022-07-16
 */
@Service
public class CommodityExchangeRecordServiceImpl extends ServiceImpl<CommodityExchangeRecordDao, CommodityExchangeRecord> implements ICommodityExchangeRecordService {

    @Autowired
    CommodityExchangeRecordDao commodityExchangeRecordDao;

    @Autowired
    UserFeedbackDao userFeedbackDao;

    //修改物流信息
    public void updateLogisticsInformation(Integer id, String logisticsInformation) {
        //查询用户现在的物流信息并且将它set好
        CommodityExchangeRecord commodityExchangeRecord = commodityExchangeRecordDao.selectById(id);
        commodityExchangeRecord.setLogisticsInformation(logisticsInformation);
        commodityExchangeRecord.setState("1");
        this.updateById(commodityExchangeRecord);
    }

    //添加反馈信息
    public void sendFeedback(SendFeedbackDTO sendFeedbackDTO) {
        UserFeedback feedback = new UserFeedback();
        feedback.setContent(sendFeedbackDTO.getContent());
        feedback.setTitle(sendFeedbackDTO.getTitle());
        feedback.setUserId(sendFeedbackDTO.getUserId());
        userFeedbackDao.insert(feedback);
    }
}
